<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>
	<button>更改颜色</button>
</body>
<script>
	const bgArr = ["red","green","blue","orange"];
	let index = 0;
	localStorage.setItem("bg",bgArr[index]);
	document.querySelector("button").onclick = function(){
		if(++index===bgArr.length) index=0;
		localStorage.setItem("bg",bgArr[index]);
	}
</script>
</html>